package com.esri.core.portal;

import com.esri.core.internal.util.d;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class FeatureCollection {
    private boolean a = false;
    private ArrayList<WebMapSubLayer> b = null;

    private FeatureCollection() {
    }

    public boolean isShowLegend() {
        return this.a;
    }

    public List<WebMapSubLayer> getLayers() {
        return this.b;
    }

    public static FeatureCollection fromJson(JsonParser jsonParser) throws Exception {
        if (d.c(jsonParser)) {
            FeatureCollection featureCollection = new FeatureCollection();
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                String currentName = jsonParser.getCurrentName();
                jsonParser.nextToken();
                if ("showLegend".equals(currentName)) {
                    featureCollection.a = jsonParser.getBooleanValue();
                } else if ("layers".equals(currentName)) {
                    if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
                        featureCollection.b = new ArrayList<>();
                        while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                            featureCollection.b.add(WebMapSubLayer.a(jsonParser));
                        }
                    } else {
                        jsonParser.skipChildren();
                    }
                }
            }
            ArrayList<WebMapSubLayer> arrayList = featureCollection.b;
            if (arrayList != null) {
                Iterator<WebMapSubLayer> it = arrayList.iterator();
                while (it.hasNext()) {
                    WebMapSubLayer next = it.next();
                    if (!next.a()) {
                        next.f = featureCollection.a;
                    }
                }
            }
            return featureCollection;
        }
        return null;
    }
}
